Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

369
Visualizações
Expo React Native socket.io listeners "went lost"

I am developing a chat app with socket.IO (frontend: React Native, backend: NodeJS). Everything works fine but sometimes messages are not sent and I discovered the problem is due to socket listeners, which sometimes went lost without an apparent reason. Infact, when mounting the component, i call useEffect to subscribe listeners like this:

useEffect(() => {
        socket.on("receiveMessage", callback);
        socket.on("receiveAck, callback);
        ... and others
},[])

if i console.log(socket._callbacks), the result is an array with the names of listeners and their relative callbacks

for example: console.log(socket._callbacks) => [ ["receiveMessage", callback function], ["receiveAck", callback function], ...]

when messages begin to not work properly, i console.log(socket._callbacks) and the result is an EMPTY ARRAY, so it's like all the listeners went lost. And the strange thing is that it happens even when the socket is correctly connected to the server (console.log(socket.connected) => true).

why this happens?

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda